package com.ysstech.common.enums;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Objects;

import com.ysstech.common.util.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 系统常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum YssEnum implements BaseEnum<String> {
    FOOTER_MSG("FOOTER_MSG", "深圳赢时胜股份有限公司 Copyright " + String.valueOf(Calendar.getInstance().get(Calendar.YEAR))),
    YSS_DEFAULT_DATE_TIME_FORMAT("yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss"),
    YSS_DEFAULT_DATE_FORMAT("yyyyMMdd", "yyyyMMdd"),
    YSS_DEFAULT_TIME_FORMAT("HH:mm:ss", "HH:mm:ss"),
    YSS_DEFAULT_DATE_TIME_FORMAT1("yyyyMMddHHmmss", "yyyyMMddHHmmss"),
    YSS_DEFAULT_DATE_TIME("yyyy-MM-dd", "yyyy-MM-dd"),
    YSS_REDIS_EXPIRATION("180000000", "shiro的reids设置不超时"),
    YSS_BATCH_SIZE("2000", "批量提交数量"),
    YSS_PAGENUM("1", "第几页"),
    YSS_PAGESIZE("20", "每页多少条"),
    YSS_TXT("txt", "txt"),
    YSS_LIC("lic", "lic"),
    YSS_SQL("sql", "sql"),
    YSS_XML("xml", "xml"),
    YSS_ZIP("zip", "zip"),
    YSS_XLSX("xlsx", "xlsx");
    private final String code;
    private final String desc;

    public static YssEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        YssEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
